package com.ruoyi.web.controller.park;

import com.ruoyi.bean.OrderFrom;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.param.ClearingParam;
import com.ruoyi.param.OrderParam;
import com.ruoyi.service.BizOrderService;
import com.ruoyi.service.OrderClearingItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "订单")
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private BizOrderService bizOrderService;
    @Autowired
    private OrderClearingItemService orderClearingItemService;

    @ApiOperation(value = "订单分页查询")
    @GetMapping("/list")
    public AjaxResult selectList(OrderParam orderParam){
        return AjaxResult.success(bizOrderService.selectList(orderParam));
    }

    @ApiOperation(value = "根据单号查询")
    @GetMapping("/get/{orderSn}")
    public AjaxResult getOrderSn(@PathVariable String orderSn){
        return AjaxResult.success(bizOrderService.getOrderSn(orderSn));
    }

    @ApiOperation(value = "修改订单")
    @Log(title = "订单管理", businessType = BusinessType.UPDATE)
    @PostMapping("")
    public AjaxResult update(@RequestBody OrderFrom orderFrom){
        return AjaxResult.success("修改成功！",bizOrderService.updateOrder(orderFrom));
    }

    @ApiOperation(value = "清分列表")
    @GetMapping("/clear/list")
    public AjaxResult selectClear(ClearingParam clearingParam){
        return AjaxResult.success("查询成功！",orderClearingItemService.selectList(clearingParam));
    }

    @ApiOperation(value="修改清分方式")
    @Log(title = "清分方式", businessType = BusinessType.UPDATE)
    @GetMapping("/clear/{id}")
    public AjaxResult updateClear(@PathVariable String id){

        return AjaxResult.success(orderClearingItemService.updateClear(id));
    }

}
